import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class GeraExecutavel {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		File f = new File("./");
		
		for (File l : f.listFiles()) {
			
			if (l.isDirectory()) { // itera pelos cenarios
				
				for (File k : l.listFiles()) {
					
					if (k.isDirectory()) { // itera pelas fontes
						
						for (File s: k.listFiles()) {
							
							if (s.isDirectory()) { // itera pelas pausas
								
								File saida = new File("./" + l.getName() + "-" + k.getName() + "-" + s.getName() + ".sh");
								BufferedWriter bw = new BufferedWriter(new FileWriter(saida));								
								
								for (File r : s.listFiles()) {
									
									if (r.isDirectory()) { // itera pelas sementes
										
										
										//geraLinhaScript(r, bw);
										geraLinhaScript2(r, bw);
										
										
									}
									
								}
								
								bw.write("cp -R /tmp/glomosim/glomosim/bin/simulacoes /home2/gustavodfc/glomosim/");
								bw.newLine();
								
								bw.flush();
								bw.close();
								
							}
							
						}
						
					}
					
				}
				
			}
			
		}
		
	}
	
	private static void geraLinhaScript2(File seed, BufferedWriter bw) throws IOException {

		bw.write("cd " + seed.getAbsolutePath());
		bw.newLine();
		bw.write("../../../../../glomosim config.in");
		bw.newLine();
	}
}
